home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2003 December / The Sunday Times - The Month 2003-12.iso / pc / engine / shell / shell.swf / scripts / DefineSprite_63 / frame_1 / DoAction.as
Encoding:
Text File  |  2003-11-10  |  4.7 KB  |  246 lines

  1. function init()
  2. {
  3.    hxColorDefault = Tardis.Colors.getHex("nav");
  4.    makeNav();
  5.    delete makeNav;
  6.    delete init;
  7.    Tardis.ChildLock.EB.addListener(this);
  8.    onComplete();
  9. }
  10. function setActive(str)
  11. {
  12.    clearActive();
  13.    objActive = this["mc_" + str];
  14.    highlightClip(objActive);
  15. }
  16. function clearActive()
  17. {
  18.    resetClip(objActive);
  19.    objActive = null;
  20. }
  21. function enable()
  22. {
  23.    var obj;
  24.    for(var o in this)
  25.    {
  26.       obj = this[o];
  27.       if(obj.enabled != undefined)
  28.       {
  29.          obj.enabled = true;
  30.       }
  31.    }
  32. }
  33. function disable()
  34. {
  35.    var obj;
  36.    for(var o in this)
  37.    {
  38.       obj = this[o];
  39.       if(obj.enabled != undefined)
  40.       {
  41.          obj.enabled = false;
  42.       }
  43.    }
  44. }
  45. function show()
  46. {
  47.    _visible = true;
  48. }
  49. function hide()
  50. {
  51.    _visible = false;
  52. }
  53. function childLockSet(val)
  54. {
  55.    var mc;
  56.    for(var o in this)
  57.    {
  58.       mc = this[o];
  59.       if(typeof mc == "movieclip" && mc._name.indexOf("kids") == -1 && mc._name.indexOf("_ha") == -1)
  60.       {
  61.          mc._visible = !val;
  62.       }
  63.    }
  64. }
  65. function splashOff()
  66. {
  67.    var mc = this["mc_" + strSplashActiveButton];
  68.    if(objActive != mc)
  69.    {
  70.       resetClip(mc);
  71.    }
  72.    strSplashActiveButton = "";
  73. }
  74. function splashOn(str)
  75. {
  76.    strSplashActiveButton = str;
  77.    highlightClip(this["mc_" + str]);
  78. }
  79. function __onOver()
  80. {
  81.    lingo("cursor 280");
  82.    if(objActive == this)
  83.    {
  84.       return undefined;
  85.    }
  86.    if(Tardis.ActiveSection == null)
  87.    {
  88.       splashOff();
  89.       splashOn(this.id);
  90.    }
  91.    else
  92.    {
  93.       highlightClip(this);
  94.    }
  95.    onOver(this.id);
  96.    updateAfterEvent();
  97. }
  98. function __onOut()
  99. {
  100.    lingo("cursor -1");
  101.    if(objActive == this)
  102.    {
  103.       return undefined;
  104.    }
  105.    if(Tardis.ActiveSection != null)
  106.    {
  107.       resetClip(this);
  108.    }
  109.    onOut();
  110.    updateAfterEvent();
  111. }
  112. function __onUp()
  113. {
  114.    if(this.disabled == "true")
  115.    {
  116.       return undefined;
  117.    }
  118.    if(objActive != this)
  119.    {
  120.       resetClip(objActive);
  121.       objActive = this;
  122.    }
  123.    onUp(this.id);
  124.    updateAfterEvent();
  125. }
  126. function makeNav()
  127. {
  128.    var len = Tardis.Sections.length;
  129.    var clp;
  130.    var nd;
  131.    var strID;
  132.    var arrClips = [];
  133.    var arrHAclips = [];
  134.    var hitareaX = 15;
  135.    var n = 0;
  136.    while(n < len)
  137.    {
  138.       var w = arrHitareaWidths[n];
  139.       nd = Tardis.Sections.item(n);
  140.       strID = nd.id;
  141.       clp = this.createEmptyMovieClip("mc_" + strID,Tardis.depth++);
  142.       clp.createTextField("txt",Tardis.depth++,0,0,100,50);
  143.       for(var o in nd)
  144.       {
  145.          clp[o] = nd[o];
  146.       }
  147.       clp.hxOverColor = Tardis.Colors.getHex(strID);
  148.       with(clp.txt)
  149.       {
  150.          embedFonts = true;
  151.          html = true;
  152.          htmlText = "<font face=\"TardisFGExtraBoldCondensed\" size=\"24\">" + nd.label + "</font>";
  153.          autoSize = "left";
  154.          textColor = hxColorDefault;
  155.       }
  156.       clp.onRollOver = __onOver;
  157.       clp.onRollOut = __onOut;
  158.       if(!(Tardis.PLAY_MODE == "browser" && nd.sandbox == "true"))
  159.       {
  160.          clp.onRelease = __onUp;
  161.       }
  162.       arrClips.push(clp);
  163.       h = clp.txt.textHeight;
  164.       clpHA = this.createEmptyMovieClip("mc_" + strID + "_ha",Tardis.depth++);
  165.       clpHA.moveTo(0,0);
  166.       clpHA.beginFill(16711680);
  167.       clpHA.lineTo(w,0);
  168.       clpHA.lineTo(w,h);
  169.       clpHA.lineTo(0,h);
  170.       clpHA.lineTo(0,0);
  171.       clpHA.endFill();
  172.       clp.hitArea = clpHA;
  173.       clpHA._visible = false;
  174.       clpHA._x = hitareaX;
  175.       hitAreaX += arrHitareaWidths[n];
  176.       n++;
  177.    }
  178.    Tardis.spaceEvenly(arrClips,15,785,null,true);
  179. }
  180. function highlightClip(mc)
  181. {
  182.    mc.txt.textColor = mc.hxOverColor;
  183.    if(faded)
  184.    {
  185.       mc._alpha = 100;
  186.    }
  187. }
  188. function resetClip(mc)
  189. {
  190.    mc.txt.textColor = hxColorDefault;
  191.    if(faded)
  192.    {
  193.       mc._alpha = FADE_LIMIT;
  194.    }
  195. }
  196. function fadeOthers(strIDExcept, strUpDown)
  197. {
  198.    var len = Tardis.Sections.length;
  199.    var strF = strUpDown != "down" ? "fadeUpEnterFrame" : "fadeDownEnterFrame";
  200.    var nd;
  201.    var strID;
  202.    var n = 0;
  203.    while(n < len)
  204.    {
  205.       nd = Tardis.Sections.item(n);
  206.       strID = nd.id;
  207.       if(strID != strIDExcept)
  208.       {
  209.          mc = this["mc_" + strID];
  210.          mc.onEnterFrame = this[strF];
  211.       }
  212.       n++;
  213.    }
  214.    this.faded = strUpDown == "down";
  215. }
  216. function fadeDownEnterFrame()
  217. {
  218.    with(this)
  219.    {
  220.       if(_alpha > FADE_LIMIT)
  221.       {
  222.          _alpha -= 10;
  223.       }
  224.       else
  225.       {
  226.          onEnterFrame = null;
  227.       }
  228.    }
  229. }
  230. function fadeUpEnterFrame()
  231. {
  232.    with(this)
  233.    {
  234.       if(_alpha < 100)
  235.       {
  236.          _alpha += 10;
  237.       }
  238.       else
  239.       {
  240.          onEnterFrame = null;
  241.       }
  242.    }
  243. }
  244. FADE_LIMIT = 50;
  245. arrHitareaWidths = [81,78,84,72,88,73,104,98,92];
  246.